package com.itheima.springboottlias.mapper;


import Pojo.Clazz;
import Pojo.ClazzQueryParam;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ClazzMapper {
    // 添加班级
    @Insert("insert into clazz values (null,#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void addClass(Clazz clazz);
    // 查询所有班级
    @Select("select * from clazz")
    List<Clazz> queryAll();
    // 查询班级
    @Select("select * from clazz where name=#{name}")
    Clazz query();
    // 分页和条件查询
    Page<Clazz> selectByCondition(ClazzQueryParam clazzQueryParam);
    // 根据id删除班级
    @Select("delete from clazz where id = #{id}")
    void removeById(Integer id);
    // 根据id查询班级
    @Select("select * from clazz where id = #{id}")
    Clazz findById(Integer id);
    // 修改班级
    @Insert("update clazz set name = #{name},room = #{room},begin_date = #{beginDate},end_date = #{endDate},master_id = #{masterId},subject = #{subject}, update_time = now(),create_time = #{createTime} where id = #{id}")
    void updateClass(Clazz clazz);
}
